package com.gm.census.controller;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.gm.census.model.pojo.Entry;
import com.gm.census.service.ServiceFactory;
import com.gm.census.service.UserInfoFacade;

@RequestMapping("/queues")
public class QueueController extends BaseController {
	public QueueController(ServiceFactory fact, UserInfoFacade userInfo) {
		super(fact, userInfo);
	}

	public enum Queues {
		entry("/queues/entry");

		private String url;

		private Queues(String url) {
			this.url = url;
		}

		public String url() {
			return url;
		}

		public String url(String id) {
			return url + "/" + id;
		}

		public String queueName() {
			return name();
		}
	}

	@RequestMapping(value = "/entry", method = RequestMethod.POST)
	public String addEntry(Entry e) {

		return "added";
	}

	@RequestMapping(value = "/entry/{id}", method = RequestMethod.DELETE)
	public String deleteEntry(@PathVariable("id") String id) {
		return "added";
	}

	@RequestMapping(value = "/entry/{id}", method = RequestMethod.PUT)
	public String indexEntry(Model m, @PathVariable("id") String id,
			@RequestHeader("usr-ns") String ns, Entry e) {
		services().getIndexService().index(id, ns, e);
		return "entry/index";
	}

}
